<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增项目')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-user-add" class="form-horizontal">
        <input name="deptId" type="hidden" id="treeId"/>
        <h4 class="form-header h4">基本信息</h4>
<!--        <div class="row">-->
<!--            <div class="col-sm-6">-->
<!--                <div class="form-group">-->
<!--                    <label class="col-sm-4 control-label is-required">托盘条码头：</label>-->
<!--                    <div class="col-sm-8">-->
<!--                        &lt;!&ndash;<input  id="tHead" name="tHead" placeholder="请输入托盘条码头" autocomplete="off" class="form-control" type="text" maxlength="20"&ndash;&gt;-->
<!--                               &lt;!&ndash;required onkeyup="addHead()">&ndash;&gt;-->
<!--                        <select  id="tHead" name="tHead"  class="form-control" required onchange="addHead()">-->
<!--                            <option value="">请选择</option>-->
<!--                            <option th:each="item:${traycodeHeadList}"-->
<!--                                    th:value="${item.tHead}" th:text="${item.tHead}">-->
<!--                            </option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">托盘条码号：</label>
                    <div class="col-sm-8">
                        <input id="trayCode" name="trayCode" placeholder="请输入托盘条码号" autocomplete="off" class="form-control" type="text" maxlength="20">
                    </div>
                </div>
            </div>


        </div>

<!--        <div class="row">-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label is-required">打印数量：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="beginCount" name="beginCount" placeholder="请输入打印数量" autocomplete="off" class="form-control" type="text" maxlength="20"-->
<!--                                   required>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->


<!--        </div>-->
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">是否使用：</label>
                    <div class="col-sm-8">
                        <select id="isUsed" name="isUsed" class="form-control" type="text">
                            <option value="Y">使用</option>
                            <option value="N">不使用</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>



        <!--<h4 class="form-header h4">其他信息</h4>-->
        <!--<div class="row">-->
            <!--<div class="col-sm-12">-->
                <!--<div class="form-group">-->
                    <!--<label class="col-xs-2 control-label">项目描述：</label>-->
                    <!--<div class="col-xs-10">-->
                        <!--<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
        <!--</div>-->


    </form>
</div>

<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script>
    var prefix = ctx + "bas/trayCode";
    var ItemCodeInfoDlg = {
        data: {
            deptId: ""
        }
    };

    // $('#tHead').bind('input propertychange', function() {addHead();});
    //
    function addHead() {
        console.log($('#tHead').val());
        var text=$('#tHead').val();
        // var text1=text.replace(/[^a-zA-Z]/g,'');
        // var text2=text1.toUpperCase();
        // $("#tHead").val(text2);
        $.ajax({
            "url": "/bas/trayCode/selectCount?tHead=" + text,
            "type": "GET",
            "dataType": "json",
            "success": function (result) {
                console.log(result);
                // var begin = result.success + 1;
                $("#beginCode").val( result+1);
            }
        });
    }

    //项目保存
    function submitHandler() {
        var password = $("#password").val();
        if ($.validate.form()) {
            var data = $("#form-user-add").serializeArray();
            $.operate.saveTab(prefix + "/adds", data);
        }
    }


    /* 选择部门树 */
    function selectDeptTree() {
        var deptId = $.common.isEmpty($("#treeId").val()) ? "1" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        selectgroup();
        layer.close(index);
    }

    //分配项目组
    function selectgroup() {
        var deptId = $("#treeId").val();
        var url = ctx + "system/item/selectPrjgroupByDeptId/" + deptId;
        $.get(url, function (result) {
            var html = ""
            for (var i = 0; i < result.length; i++) {
                html += "<option  value=" + result[i].prjgroupId + ">" + result[i].prjgroupName + "</option>"
            }
            $("#prjGroup").html(html)
            console.log(result)
        })

    }
    //分配项目参与人员
    /*function selectelopy() {
        var deptId = $("#treeId").val();
        var url = ctx + "system/item/selectEmployeeByDeptId/" + deptId;
        $.get(url, function (result) {
            console.log(result)
            var html = ""
            for (var i = 0; i < result.length; i++) {
                html += "<option  value=" + result[i].employeeId + ">" + result[i].name + "</option>"
            }
            $("#emplyIds").html(html)
            console.log(result)
        })

    }*/
</script>
</body>
</html>